package demo_3;

import com.alibaba.fastjson.JSON;

/**
 * 类描述：优美的排列 II
 *
 * @author lwj
 */
public class Demo_3 {

    public static final Integer n = 10;
    public static final Integer k = 3;


    public static void main(String[] args) {
        if (n <= 0 || k <= 0 || k >= n) {
            System.out.println("不存在");
            return;
        }
        boolean nIsBefore = k % 2 == 0;
        int number = k / 2;
        System.out.println("number:" + number);
        System.out.println("nIsBefore:" + nIsBefore);
        int point = 0;
        Integer[] res = new Integer[n];
        for (int i = 0; i < n; i++) {
            if (point < number && nIsBefore) {
                res[i] = n - point;
                i++;
            }
            res[i] = ++point;
            if (point <= number && !nIsBefore) {
                i++;
                res[i] = n - point + 1;
            }
        }
        System.out.println(JSON.toJSONString(res));
    }
}